#include <iostream>
#include <string>
#include <unistd.h>
#include <pthread.h>

// 线程理论验证

void *start_rontine(void *args)
{
    std::string name = (char *)args;
    while (true)
    {
        sleep(1);
        std::cout << "我是新线程，name：" << name << " ，pid：" << getpid() << std::endl;
        // 验证异常
        //  int a = 10;
        //  a /= 0;
    }

    return nullptr;
}

int main()
{
    pthread_t tid;
    pthread_create(&tid, nullptr, start_rontine, (char *)"thread_1");

    while (true)
    {
        std::cout << "我是主线程...，pid：" << getpid() << std::endl;
        sleep(1);
    }

    return 0;
}